<?php
	$worker = isset($_GET['worker']) ? $_GET['worker'] : 1;
?>
<html>
	<head>
		<title>JS Run</title>
		<style type="text/css">
			html,body { display:block; width:100%; height:100%; text-align:center; font-family:Verdana; }
			body { position:relative; background:#e4e4e4; }
			.table { display:block; width:100%; position:relative; padding:10px; }
			.table table { background:white; }
			.table th { background:#aaa; }
		</style>
		<script src="js/thread.min.js" type="text/javascript"></script>
	</head>
	<body>
		<h2>Threaded table creation.</h2>
		<div id="table" class="table"></div>
		<!--[if IE]>
		<script src="js/worker.min.js" type="text/javascript"></script>
		<![endif]-->
		<script type="text/javascript">
				var len = 100000;
					
					var start = new Date(),
						event = {
							src:'js/test1.js',
							data:len,
							onsuccess: (function(e) {
								document.getElementById('table').innerHTML = e.data;
							})
						};
				
				// no threads
				function noThreads(len) {
					var html = ['<table><tr><th>Row</th><th>Value</th></tr>'];
					for (var i = 0; i < len; ++i) {
						html.push('<tr><td>Row #</td><td>');
						html.push(i);
						html.push('</td></tr>');
					}
					html.push('</table>');

					document.getElementById('table').innerHTML = html.join('');
				}
				
				if (<?= $worker ? 'false' : 'true' ?>) {
					noThreads(len);
				}
				else {
					(new Thread()).start(event);
				}
				
				alert('Hello World!');
		</script>
	</body>
</html>